*use "Mous_IS_2019_SourceData.dta"

*Source data:
*kappava and pivv: Frank M. Häge, “Chance-Corrected Measures of Foreign Policy Similarity (FPSIM Version 2),” Harvard Dataverse, V1, https://doi.org/10.7910/DVN/ALVXLM. As recommended, alliance agreement is gauged using the Kappava variable and voting agreement is gauged using the Pivv variable. See Frank M. Häge, “Choice or Circumstance? Adjusting Measures of Foreign Policy Similarity for Chance Agreement,” Political Analysis, Vol. 19, No. 3 (Summer 2011), pp. 287–305, doi.org/10.1093/pan/mpr023. Alliance data are originally from Douglas M. Gibler, International Military Alliances, 1648–2008 (Washington, D.C.: CQ Press, 2009). United Nations General Assembly voting data are originally from Erik Voeten, “Data and Analyses of Voting in the United Nations General Assembly,” in Bob Reinalda, ed., Routledge Handbook of International Organization (London: Routledge, 2013).
*cinc and tpop: J. David Singer, Stuart A. Bremer, and John Stuckey, “Capability Distribution, Uncertainty, and Major Power War, 1820-1965,” in Peace, War, and Numbers, ed. Bruce Russett (Beverly hills, CA: SAGE, 1972).
*ExGdsServ: World Development Indicators (Washington, D.C.: The World Bank, 2016).
*CIEb and axial: Contract Intensity of National Economies (CINE), Version Mar-2019

tsset ccode year
corr kappava pivv

g LA=0
replace LA=1 if ccode <200
replace LA=0 if ccode==20|ccode==40
g NATO=0
replace NATO=1 if year >=1949 & ccode==20|ccode==200|ccode==210|ccode==211|ccode==212|ccode==220|ccode==390|ccode==395|ccode==325|ccode==385|ccode==235
replace NATO=1 if year >=1952 & ccode==350 |ccode==640
replace NATO=1 if year >=1955 & ccode==255
replace NATO=1 if year >=1955 & ccode==260
replace NATO=1 if year >=1982 & ccode==230
replace NATO=1 if year >=1999 & ccode==355|ccode==366|ccode==367|ccode==368|ccode==360|ccode==317|ccode==349
replace NATO=1 if year >=2009 & ccode==339|ccode==344

egen mdDV=median(kappava)  
egen sdDV=sd(kappava)  
g kallied=( kappava -mdDV)/sdDV
drop mdDV sdDV
sum kallied if LA==1, d
sum kallied if NATO==1, d

g mjpw=0
replace mjpw=1 if ccode==2|ccode==200|ccode==220|ccode==365
replace mjpw=1 if year > 1949 & ccode==710
replace mjpw=1 if year > 1990 & ccode==740
replace mjpw=1 if year > 1990 & ccode==255

g expc= ln(ExGdsServ/tpop)
sum expc, d
* 50%     13.50164 (median)
g EXPb=1 if expc>= 13.50164 & expc ~=.
replace EXPb =0 if expc< 13.50164 & expc ~=.

rename cinc cinc1
egen mdcinc=median(cinc1)  
egen sdcinc=sd(cinc1)  
g cinc= ((cinc1-mdcinc)/sdcinc ) 
drop mdcinc sdcinc

g CIEbcinc= CIEb*cinc
g EXPbcinc= EXPb*cinc

g CIEbmjpw=0 if CIEb~=.
replace CIEbmjpw=1 if CIEb==1 & mjpw==1
g CIEbmnpw=0 if CIEb~=.
replace CIEbmnpw=1 if CIEb==1 & mjpw==0
g CLNbmjpw=0 if CIEb~=.
replace CLNbmjpw=1 if CIEb==0 & mjpw==1
g CLNbmnpw=0 if CIEb~=.
replace CLNbmnpw=1 if CIEb==0 & mjpw==0

g EXPmjpw=0 if EXPb~=.
replace EXPmjpw=1 if EXPb==1 & mjpw==1
g EXPmnpw=0 if EXPb~=.
replace EXPmnpw=1 if EXPb==1 & mjpw==0
g INSmjpw=0 if EXPb~=.
replace INSmjpw=1 if EXPb==0 & mjpw==1
g INSmnpw=0 if EXPb~=.
replace INSmnpw=1 if EXPb==0 & mjpw==0

egen mdDV=median(pivv)  
egen sdDV=sd(pivv)  
g pagree=( pivv -mdDV)/sdDV
drop mdDV sdDV

*T2: 
reg pagree CIEbmjpw CIEbmnpw CLNbmjpw, cl(ccode)
reg pagree EXPmjpw EXPmnpw INSmjpw, cl(ccode)
*T3:
reg pagree CIEbcinc CIEb cinc, cl(ccode)
corr CIEbcinc CIEb if pagree~=., covariance
reg pagree EXPbcinc EXPb cinc, cl(ccode)
corr EXPbcinc EXPb if pagree~=., covariance

*Further Tests:

*Contractualist nondemocracy dropped:
drop if ccode== 732 & year >=1984 & year <=1987
drop if ccode== 820 & year >=1996 & year <=2007
drop if ccode== 830 & year >=1994
*T2: 
reg pagree CIEbmjpw CIEbmnpw CLNbmjpw, cl(ccode)
reg pagree EXPmjpw EXPmnpw INSmjpw, cl(ccode)
*T3:
reg pagree CIEbcinc CIEb cinc, cl(ccode)
corr CIEbcinc CIEb if pagree~=., covariance
reg pagree EXPbcinc EXPb cinc, cl(ccode)
corr EXPbcinc EXPb if pagree~=., covariance


*Axial treated as contractualist:
use "C:\Users\mi583826\OneDrive - University of Central Florida\Publications and Datasets\IS New Liberal Theory\Mous_IS_2019_SourceData.dta", clear

tsset ccode year
replace CIEb=1 if axial==1

g mjpw=0
replace mjpw=1 if ccode==2|ccode==200|ccode==220|ccode==365
replace mjpw=1 if year > 1949 & ccode==710
replace mjpw=1 if year > 1990 & ccode==740
replace mjpw=1 if year > 1990 & ccode==255

g expc= ln(ExGdsServ/tpop)
* 50%     13.50164 (median)
g EXPb=1 if expc>= 13.50164 & expc ~=.
replace EXPb =0 if expc< 13.50164 & expc ~=.

rename cinc cinc1
egen mdcinc=median(cinc1)  
egen sdcinc=sd(cinc1)  
g cinc= ((cinc1-mdcinc)/sdcinc ) 

g CIEbcinc= CIEb*cinc
g EXPbcinc= EXPb*cinc

g CIEbmjpw=0 if CIEb~=.
replace CIEbmjpw=1 if CIEb==1 & mjpw==1
g CIEbmnpw=0 if CIEb~=.
replace CIEbmnpw=1 if CIEb==1 & mjpw==0
g CLNbmjpw=0 if CIEb~=.
replace CLNbmjpw=1 if CIEb==0 & mjpw==1
g CLNbmnpw=0 if CIEb~=.
replace CLNbmnpw=1 if CIEb==0 & mjpw==0

g EXPmjpw=0 if EXPb~=.
replace EXPmjpw=1 if EXPb==1 & mjpw==1
g EXPmnpw=0 if EXPb~=.
replace EXPmnpw=1 if EXPb==1 & mjpw==0
g INSmjpw=0 if EXPb~=.
replace INSmjpw=1 if EXPb==0 & mjpw==1
g INSmnpw=0 if EXPb~=.
replace INSmnpw=1 if EXPb==0 & mjpw==0

egen mdDV=median(pivv)  
egen sdDV=sd(pivv)  
g pagree=( pivv -mdDV)/sdDV
drop mdDV sdDV

*T2: 
reg pagree CIEbmjpw CIEbmnpw CLNbmjpw, cl(ccode)
*T3:
reg pagree CIEbcinc CIEb cinc, cl(ccode)
corr CIEbcinc CIEb if pagree~=., covariance




